package t2;

public class Test {

	public static void main(String[] args) {
		
		int[][] item = {{1,3,6},{2,4,8},{5,7,9}};
		int[] array = new int[9];
		int index = 0;
		
		//遍历二维数组，将其转换成一维数组
		for(int i=0;i<item.length;i++){
			for(int j=0;j<item[i].length;j++){
				array[index] = item[i][j];
				index++;
			}
		}
		
		//对一维数组排序
		for(int i=0;i<array.length-1;i++){
			for(int j=0;j<array.length-1-i;j++){
				if(array[j]>array[j+1]){
					int temp = array[j];
					array[j] = array[j+1];
					array[j+1] = temp;
				}
			}
		}
		
		//打印输出
		for(int i=0;i<array.length;i++){
			if(i!=0&&i%3==0){
				System.out.println();
			}
			System.out.print(array[i]+" ");
		}
	}
	
}
